/*
package com.ruiyi.subway.utils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.util.List;

import org.apache.commons.io.IOUtils;

import com.google.common.reflect.TypeToken;
import com.yuancore.common.gson.Gson;
import com.yuancore.vcs.common.exception.StoreException;

public class JsonParser {

    public static <T> InputStream objectToStream(T object) throws StoreException {
        try {
            String jsonStr = new Gson().toJson(object);
            return new ByteArrayInputStream(jsonStr.getBytes("utf-8"));
        } catch (UnsupportedEncodingException e) {
            throw new StoreException("对象转换为Inputstream失败", e);
        }
    }

    public static <T> T streamToObject(InputStream content, Class<T> objectClass) throws StoreException {
        try {
            if (content == null) {
                return null;
            }
            String jsonStr = IOUtils.toString(content, "utf-8");
            return new Gson().fromJson(jsonStr, objectClass);
        } catch (IOException e) {
            throw new StoreException("Inputstream转换为对象失败", e);
        } finally {
            IOUtils.closeQuietly(content);
        }
    }

    public static <T> List<T> streamToList(InputStream content, Class<T> itemClass) throws StoreException {
        try {
            if (content == null) {
                return null;
            }
            String jsonStr = IOUtils.toString(content, "utf-8");
            Type type = new TypeToken<List<T>>() {
            }.getType();
            return new Gson().fromJson(jsonStr, type);
        } catch (IOException e) {
            throw new StoreException("Inputstream转换为List失败", e);
        } finally {
            IOUtils.closeQuietly(content);
        }
    }

    public static <T> T stringToObject(String json, Class<T> objectClass){
        if (json == null || "".equals(json)) {
            return null;
        }
        return new Gson().fromJson(json, objectClass);
    }

    public static <T> List<T> stringToList(String json, Class<T> itemClass) throws StoreException {

        if (json == null || "".equals(json)) {
            return null;
        }
        Type type = new TypeToken<List<T>>() {
        }.getType();
        return new Gson().fromJson(json, type);
    }

}
*/
